<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>addschoolchild</title>
    <link rel="stylesheet" href="css/layui/css/layui.css">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/add_school.css">
    <link rel="stylesheet" href="css/public/public.css">
    <link rel="stylesheet" href="css/font-awesome-4.7.0/css/font-awesome.css">
    <style>
        #com_add,
        #rec_add,
        #tianjia_sub {
            display: none;
        }
    </style>
</head>

<body id="main">
    <span id="recordId" style="display: none;"></span>
    <!-- 基本信息222 -->
    <div class="essential_information clear">
        <form id="pubForm">
            <div class="left_inp">
                <!-- 基本信息 -->
                <div class="school">
                    <div class="msg">
                        <h3>基本信息</h3>
                    </div>
                    <div class="inp">
                        <label for="schoolname">院校名称</label>
                        <input type="text" name="schoolname" id="schoolname" value="家里蹲大学" placeholder="请输入院校名称">
                    </div>
                    <div class="inp">
                        <label for="department">院系</label>
                        <input type="text" name="department" id="department" placeholder="请输入院系">
                    </div>
                    <div class="inp">
                        <label for="learnyear">学制</label>
                        <input type="text" name="learnyear" id="learnyear" placeholder="学制">
                    </div>
                    <div class="inp">
                        <label>所在地区</label>
                        <select name="area_pri" id="area_pri">
                            <!-- <option value="0" selected>河南省</option>
                            <option value="1">安徽省</option>
                            <option value="2">上海省</option> -->
                        </select>
                        <select name="area_city" id="area_city">
                        </select>
                    </div>
                    <div class="inp">
                        <label for="affiliated">所属部门</label>
                        <input type="text" name="affiliated" id="affiliated" placeholder="所属部门">
                        <!-- <datalist id="affiliat">
                            <option>渠道一部</option>
                            <option>渠道二部</option>
                            <option>渠道三部</option>
                        </datalist> -->
                    </div>
                    <div class="inp">
                        <label for="schoolsite">院校地址</label>
                        <input type="text" name="schoolsite" id="schoolsite" placeholder="请输入院校地址">
                    </div>
                    <div class="inp">
                        <label for="synopsis">院校简介</label>
                        <input type="text" name="synopsis" id="synopsis" placeholder="请输入院校简介">
                    </div>
                </div>
                <!-- 院系联系人 -->
                <div class="teacher">
                    <div class="msg">
                        <h3>院系联系人</h3>
                    </div>
                    <div class="tea_inp">
                        <label for="teacher_name">院系联系人姓名</label>
                        <input type="text" name="teacher_name" id="teacher_name" placeholder="院系联系人姓名">
                    </div>
                    <div class="tea_inp">
                        <label for="teacher_tel">院系联系人电话</label>
                        <input type="tel" name="teacher_tel" id="teacher_tel" placeholder="院系联系人电话">
                    </div>
                </div>
            </div>
            <div class="right_inp">
                <div class="student_msg">
                    <div class="msg">
                        <h3>学生数据信息</h3>
                    </div>
                    <div class="stu_mag">
                        <label for="studentcount">目标学员数量</label>
                        <input type="text" name="studentcount" id="studentcount" placeholder="目标学员数量">
                    </div>
                    <div class="stu_mag">
                        <label for="predictcount">预计报名人数</label>
                        <input type="text" name="predictcount" id="predictcount" placeholder="预计报名人数">
                    </div>
                    <div class="stu_mag">
                        <label for="practicalcount">实际招生人数</label>
                        <input type="text" name="practicalcount" id="practicalcount" placeholder="实际招生人数">
                    </div>
                    <div class="stu_mag">
                        <span class="fa fa-table" id="away_stu_time"></span>
                        <span class="fa fa-times-circle-o" id="away_close"></span>
                        <label for="awaytime">学生离校时间</label>
                        <input type="text" name="awaytime" id="awaytime" placeholder="离校时间">
                    </div>
                    <div class="stu_mag">
                        <label for="activitymode">预计活动方式</label>
                        <input type="text" name="activitymode" id="activitymode" placeholder="预计活动方式">
                        <!-- <datalist id="activity_list">list="activity_list"
                            <option>实训</option>
                            <option>讲座</option>
                            <option>宣讲</option>
                        </datalist> -->
                    </div>
                    <div class="stu_mag">
                        <span class="fa fa-table" id="plat_time"></span>
                        <span class="fa fa-times-circle-o" id="play_close"></span>
                        <label for="activitytime">计划活动时间</label>
                        <input type="text" name="activitytime" id="activitytime" placeholder="活动时间">
                    </div>
                </div>
                <div class="proportion">
                    <div class="msg">
                        <h3>考研/专升本比例</h3>
                    </div>
                    <div class="pro_exams">
                        <label for="exams">考研比例</label>
                        <input type="text" name="exams" id="exams" placeholder="考研比例">
                    </div>
                    <div class="pro_exams">
                        <label id="ex" for="go_exams">专升本比例</label>
                        <input type="text" name="go_exams" id="go_exams" placeholder="专升本比例">
                    </div>
                </div>
                <div class="later">
                    <div class="msg">
                        <h3>本公司以往招生信息</h3>
                    </div>
                    <div class="later_msg">
                        <label for="later_activity">以往活动方式</label>
                        <input type="text" name="later_activity" id="later_activity" list="later_list"
                            placeholder="活动方式">
                        <datalist id="later_list">
                            <option>口碑</option>
                            <option>网资</option>
                            <option>地摊</option>
                            <option>社招</option>
                            <option>合作企业</option>
                        </datalist>
                    </div>
                    <div class="later_msg">
                        <label for="later_activity_count">以往活动总数</label>
                        <input type="text" name="later_activity_count" id="later_activity_count" placeholder="活动总数">
                    </div>
                    <div class="later_msg ex">
                        <label for="later_stu_count">以往招生总数</label>
                        <input type="text" name="later_stu_count" id="later_stu_count" placeholder="以往招生总数">
                    </div>
                </div>
            </div>
        </form>
        <!-- 竞争对手 -->
        <div class="msg competitor">
            <div class="com_top">
                <h3>竞争对手</h3>
                <a id="com_add" href="javascript:void(0)"><span class="fa fa-plus"></span>添加</a>
            </div>
            <form style="display: block;">
                <div class="com_inp">
                    <label for="companyname">公司名称</label>
                    <input type="text" name="companyname" id="companyname" placeholder="公司名称">
                </div>
                <div class="clear">
                    <div class="com_inp">
                        <label for="competitive">竞争学科</label>
                        <input type="text" name="competitive" id="competitive" placeholder="竞争学科">
                    </div>
                    <div class="com_inp">
                        <label for="learnmoney">学费金额</label>
                        <input type="text" name="learnmoney" id="learnmoney" placeholder="学费金额">
                    </div>
                </div>
                <div class="clear">
                    <div class="com_inp">
                        <label for="recruit_stu">招生方式</label>
                        <input type="text" name="recruit_stu" id="recruit_stu" placeholder="招生方式">
                    </div>
                    <div class="com_inp">
                        <label for="recruit_count">招生人数</label>
                        <input type="text" name="recruit_count" id="recruit_count" placeholder="招生人数">
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!-- 记录信息 -->
    <div class="msg recorded">
        <div class="com_top">
            <h3>记录信息</h3>
        </div>
        <div class="add_msg" style="background-color: #fff;display: block;">
            <label for="textarea">记录内容</label>
            <textarea name="textarea" id="textarea" placeholder="请输入记录内容"></textarea>
        </div>
        <div class="tianjia">
            <p id="rec_add"><span class="fa fa-plus"></span> 添加记录</p>
            <p id="tianjia_sub"><span class="fa fa-upload"></span>提交</p>
        </div>
    </div>
</body>
<script src="js/jquery-3.4.1.js"></script>
<script src="js/ipUrl.js"></script>
<script src="css/layui/layui.js"></script>
<script src="js/add_school.js"></script>
<script src="js/add_school_child.js"></script>
<script>
    var thisId = localStorage.getItem('thisId');
    console.log(thisId)
    $.ajax({
        url: addSchoolURL + ":9999/oaSystem/school",
        type: "get",
        dataType: "json",
        data: {
            "method": "oneschool",
            "id": thisId
        },
        success: function (data) {
            console.log(data);
            $("#schoolname").val(data.result.schoolName);
            $("#department").val(data.result.department);
            $("#learnyear").val(data.result.education);
            $("#area_pri").find('select:option').text(data.result.address);
            $("#affiliated").val(data.result.competentDept);
            $("#schoolsite").val(data.result.address);
            $("#synopsis").val(data.result.desc);
            $("#teacher_name").val(JSON.parse(data.result.departConnection).name);
            $("#teacher_tel").val(JSON.parse(data.result.departConnection).tel);
            $("#studentcount").val(data.result.targetStudentSum);
            $("#predictcount").val(data.result.planRecruitNum);
            $("#practicalcount").val(data.result.realityNum);
            $("#awaytime").val(data.result.leaveTime);
            $("#activitymode").val(data.result.planActivity);
            $("#activitytime").val(data.result.activityTime);
            $("#exams").val(data.result.postgraduateExam);
            $("#go_exams").val(data.result.topUpExam);
            $("#later_activity").val(data.result.beforeActivity);
            $("#later_activity_count").val(data.result.beforeStudySum);
            $("#later_stu_count").val(data.result.beforeRecruitNum);
            $("#recordId").html(data.result.recordId);
        },
        error: function (xhr, error) {
            console.error(error);
        }
    });
    // 省份
    $.ajax({
        url: addSchoolURL + ":9999/oaSystem/school",
        type: 'get',
        data: {
            "method": "province"
        },
        dataType: 'json',
        success: function (data) {
            if (data.code == 100) {
                // upDown();
                var list = data.result;
                for (var i = 0; i < list.length; i++) {
                    var oPtion = '<option value="' + list[i].id + '">' + list[i].name + '</option>';
                    $("#area_pri").append(oPtion);
                }
            }
        },
        error: function (xhr, errorType) {
            console.log(errorType);
        }
    });
    // $(".reg_list").on('click','option',function() {
    // 	$("#region").val($(this).html());
    // });
    // 市区ajax
    $("#area_pri").on('change', function () {
        $("#area_city").empty();
        var valId = $(this).val();
        $.ajax({
            url: addSchoolURL + ":9999/oaSystem/school",
            type: 'get',
            data: {
                "method": "cityandarea",
                "parent_id": valId
            },
            dataType: 'json',
            success: function (data) {
                if (data.code == 100) {
                    // console.log(data)
                    var citylist = data.result;
                    for (var i = 0; i < citylist.length; i++) {
                        var oPtion = '<option value="' + citylist[i].id + '">' + citylist[i].name + '</option>';
                        $("#area_city").append(oPtion);
                    }
                }
            },
            error: function (xhr, errorType) {
                console.log(errorType);
            }
        });
    });
    // 提交按钮
    $("#tianjia_sub").click(function () {
        var cDapart = '{"name"' + ':' + '"' + $("#teacher_name").val() + '"' + ',' + '"tel"' + ':' + '"' + $("#teacher_tel").val() + '"}';
        var compet = '{"name"' + ':' + '"' + $("#companyname").val() + '"' + ',' + '"tive"' + ':' + '"' + $("#competitive").val() + '"' + ',' + '"money"' + ':' + '"' + $("#learnmoney").val() + '"' + ',' + '"recruitstu"' + ':' + '"' + $("#recruit_stu").val() + '"' + ',' + '"recruitcou"' + ':' + '"' + $("#recruit_count").val() + '"}';
        var dataStr = localStorage.getItem('jsonId');//获取key为jsonId的localStrage的value
        var dataJson = eval("(" + dataStr + ")");//使用eval方法将String类型的数据转化为JSON类型
        console.log(dataJson.result[0].empId)
        $.ajax({
            url: addSchoolURL + ':9999/oaSystem/school',
            type: 'get',
            data: {
                "id": thisId,
                "method": 'updateschool',
                "schoolName": $("#schoolname").val(),
                // schoolCode:$("#schoolname").val(),
                "competentDept": $("#affiliated").val(),
                "address": $("#schoolsite").val(),
                "education": $("#learnyear").val(),
                "desc": $("#synopsis").val(),
                // inputId:$("#schoolname").val(),
                // inputTime:$("#schoolname").val(),
                // modifyId:$("#schoolname").val(),
                // modifyTime:$("#schoolname").val(),
                // acquireId:$("#schoolname").val(),
                // acquireTime:$("#schoolname").val(),
                "department": $("#department").val(),
                "departConnection": cDapart,
                "modifyId": dataJson.result[0].empId,//员工id
                // "acquireId": dataJson.result[0].empId,//领取人id
                "targetStudentSum": $("#studentcount").val(),
                // beforeStudySum:$("#later_stu_count").val(),
                "postgraduateExam": $("#exams").val(),
                "topUpExam": $("#go_exams").val(),
                "competition": compet,
                "beforeRecruitNum": $("#later_stu_count").val(),
                "beforeActivity": $("#later_activity").val(),
                "planActivity": $("#activitymode").val(),
                "planRecruitNum": $("#predictcount").val(),
                "activityTime": $("#activitytime").val(),
                "leaveTime": $("#awaytime").val(),
                "realityNum": $("#practicalcount").val(),
                "recordId":$("#recordId").html()
                // recordId:$("#practicalcount").val()
            },
            dataType: 'json',
            success: function (data) {
                console.log(data);
                window.location.href = 'academy_child_add.html';
            },
            error: function (xhr, error) {
                console.error(error);
            }
        });
    });
</script>

</html>